<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <input type="text" name="" id="num" placeholder="请输入一个数" />
    <button>验证</button>
  </body>
</html>
<script>
  var btn = document.querySelector("button");
  var num1 = document.querySelector("#num");
  btn.onclick = function () {
    if (num1.value.trim() == "") return alert("请输入内容");
    if (isNaN(num1.value)) return alert("请输入数字");
    if (num1.value == "0") {
      alert("无效输入");
    } else if (num1.value % 5 == "0") {
      alert(num1.value + "该数能被5整除");
    } else {
      alert(num1.value + "该数不能被整除");
    }
  };
</script>
